<template>
  <div class="app-container">
    <SearchForm
      v-show="showSearch"
      v-model="queryParams"
      :options="[]"
      @onQuery="getList"
    >
      <template #default="{ filterForm, handleQuery }">
        <el-form-item label="装置名称">
          <el-input
            v-model="filterForm.deviceName"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="所属部门">
          <el-input
            v-model="filterForm.deptName"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单元名称">
          <el-input
            v-model="filterForm.analysisUnit"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="检查人员">
          <el-input
            v-model="filterForm.checkUserNames"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="排查内容">
          <el-input
            v-model="filterForm.hiddenContent"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="风险事件">
          <el-input
            v-model="filterForm.dangerEvent"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
        <el-form-item label="任务状态">
          <el-input
            v-model="filterForm.taskState"
            style="width: 100%"
            @change="handleQuery"
          />
        </el-form-item>
      </template>
    </SearchForm>
    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd"
          >新增</el-button
        >
      </el-col> -->

      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:user:remove']"
          >删除</el-button
        >
      </el-col> -->

      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <Table
      ref="table"
      :auto-featch="true"
      :fetch-data="fetchData"
      :options="[]"
      actionWidth="100"
    >
      <template #default>
        <el-table-column
          label="所属部门"
          align="center"
          key="deptName"
          prop="deptName"
          width="150"
          show-overflow-tooltip
        />
        <el-table-column
          label="装置名称"
          align="center"
          key="deviceName"
          prop="deviceName"
          width="150"
          show-overflow-tooltip
        />
        <el-table-column
          label="单元名称"
          key="analysisUnit"
          prop="analysisUnit"
          width="150"
          show-overflow-tooltip
        />
        <el-table-column
          label="风险事件"
          align="center"
          width="300"
          key="dangerEvent"
          prop="dangerEvent"
          show-overflow-tooltip
        />
        <el-table-column
          label="排查内容"
          align="center"
          width="450"
          key="hiddenContent"
          prop="hiddenContent"
          show-overflow-tooltip
        />
        <el-table-column
          label="周期次数"
          align="center"
          key="cycle"
          prop="cycle"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          label="周期单位"
          show-overflow-tooltip
          align="center"
          key="unit"
          prop="unit"
        >
        </el-table-column>

        <el-table-column
          label="任务开始时间"
          align="center"
          width="200"
          key="taskStartTime"
          prop="taskStartTime"
          show-overflow-tooltip
        />
        <el-table-column
          label="检查人员"
          align="center"
          width="200"
          key="checkUserNames"
          prop="checkUserNames"
          show-overflow-tooltip
        />
        <el-table-column
          label="任务状态"
          align="center"
          width="150"
          key="taskState"
          prop="taskState"
          show-overflow-tooltip
        >
        </el-table-column>
      </template>

      <template #actionButton="{ row }">
        <el-button type="text" @click="handleDetail(row)">详情</el-button>
      </template>
      <template #dangerNames="{ row }">
        {{ row.dangerName }}
      </template>
    </Table>
    <el-dialog v-model="outerVisible" width="90%" title="排查记录详情">
      <template #default>
        <Inner ref="inner" :parentNode="parentNode"></Inner>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import Table from "@/components/Table/index.vue";
import SearchForm from "@/components/searchForm/index";
import { apis as APIS } from "@/api/yhpc/yhpcrwpz.js";
import { useAsyncData } from "@/views/hooks/useAsyncData.js";
import Inner from "./components//inner";
const { proxy } = getCurrentInstance();
const inner = ref();
const parentNode = ref({});
const outerVisible = ref(false);
const handleDetail = (row) => {
  outerVisible.value = true;
  nextTick().then(() => {
    parentNode.value = row;
    // inner.value.changeParent(row);
  });
};

const showSearch = ref(true);
const dialogVform = ref();
const table = ref();

const { fetchData, handleAdd, getList, queryParams, form, handleExport } =
  useAsyncData({
    APIS: {
      ...APIS,
      url: "/preventionCheckTaskConfig/",
    },
    dialogVform,
    table,
    proxy,
  });
</script>

<style lang="scss" scoped></style>
